//
//  ST_MatchFaceSuccessController.swift
//  btvideo
//
//  Created by mac on 2020/3/18.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit
import SwifterSwift
import SnapKit


/**
 匹配face成功
 */
class ST_MatchFaceSuccessController: ST_BTLightBarViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.title_nav_btn.setTitleForAllStates("真人头像认证")
        set_up_right_btn()
        
        view.addSubview(imageView)
        imageView.snp.makeConstraints { (make) in
            make.top.equalTo(own_navigation_bar.snp.bottom).offset(40)
            make.centerX.equalToSuperview()
        }
        
        view.addSubview(match_title_label)
        match_title_label.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(imageView.snp.bottom).offset(20)
        }
        view.addSubview(match_sub_title_label)
        match_sub_title_label.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(match_title_label.snp.bottom).offset(10)
        }
        
        
        view.addSubview(privilege_title_label)
        privilege_title_label.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.top.equalTo(match_sub_title_label.snp.bottom).offset(30)
            make.height.equalTo(25)
        }
        
        
               
            var lastVerticalView:ST_AICenterFaceStatusCellChildBox?
            
            for (idx,item) in ST_AICenterFaceStatusCellChildBoxModel.setup_data().enumerated(){
                
                let rowIndex = idx % 2
                
                let itemView = ST_AICenterFaceStatusCellChildBox()
                
    //            itemView.backgroundColor = .random
                
                itemView.model = item
                view.addSubview(itemView)
                
                if rowIndex == 0{
                    itemView.snp.makeConstraints { (make) in
                        make.size.equalTo(ST_AICenterFaceStatusCellChildBox.size)
                        make.right.equalTo(view.snp.centerX).offset(-7)
                        
                        if let last = lastVerticalView{
                            make.top.equalTo(last.snp.bottom).offset(15)
                        }else{
                            make.top.equalTo(privilege_title_label.snp.bottom).offset(20)
                        }
                    }
                }else{
                    
                    itemView.snp.makeConstraints { (make) in
                        make.size.equalTo(ST_AICenterFaceStatusCellChildBox.size)
                        make.left.equalTo(view.snp.centerX).offset(8)
                        if let last = lastVerticalView{
                            make.top.equalTo(last)
                        }else{
                            make.top.equalTo(privilege_title_label.snp.bottom).offset(20)
                        }
                    }
                }
                if rowIndex == 0{
                    lastVerticalView = itemView
                }
            }
            
        
     
        self.left_nav_btn.isHidden = true
    }
    
    fileprivate func set_up_right_btn(){
        
        right_nav_btn.setTitleForAllStates("完成")
        right_nav_btn.titleLabel?.font = UIFont.systemFont(ofSize: 15, weight: UIFont.Weight.semibold)
        right_nav_btn.backgroundColor = Color.init(hexString: "#FEC207")
        right_nav_btn.cornerRadius = 15
        right_nav_btn.snp.remakeConstraints { (make) in
            make.right.equalTo(own_navigation_bar).offset(-15)
            make.centerY.equalTo(title_nav_btn)
            make.width.equalTo(60)
            make.height.equalTo(30)
        }
        right_nav_btn.isHidden = false
        
    }
    
    override func right_click() {
        
        goback_previous_controller()
    }
    
//    MARK: - Properties
    fileprivate lazy var imageView:UIImageView = {
       let control = UIImageView()
        control.image = ST_ImageUtils.imageName("个人中心_img_认证成功")
        return  control
    }()
    
    fileprivate lazy var match_title_label:UILabel = {
       let label = UILabel()
       let attrString = NSMutableAttributedString(string: "认证成功！")
        let attr: [NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 18, weight: UIFont.Weight.medium),.foregroundColor: UIColor(red: 0.4, green: 0.4, blue: 0.4, alpha: 1)]
       attrString.addAttributes(attr, range: NSRange(location: 0, length: attrString.length))
        label.attributedText = attrString
       return label
    }()

    fileprivate lazy var match_sub_title_label:UILabel = {
       let label = UILabel()
        label.numberOfLines = 0
       let attrString = NSMutableAttributedString(string: "恭喜你获得了真人头像认证！现在你可以对\n心仪的对象发起喜欢了！")
        
        let parag = NSMutableParagraphStyle()
        parag.alignment = .center
        parag.lineSpacing = 5
        
        let attr: [NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular),.foregroundColor: UIColor.init(hex: 0xACB4C0)!,.paragraphStyle:parag]
        
       attrString.addAttributes(attr, range: NSRange(location: 0, length: attrString.length))
        
        label.attributedText = attrString
       return label
    }()
    
    
    fileprivate lazy var privilege_title_label:UILabel = {
       let label = UILabel()
       let attrString = NSMutableAttributedString(string: "恭喜获得认证福利")
        let attr: [NSAttributedString.Key : Any] = [.font: UIFont.systemFont(ofSize: 18, weight: UIFont.Weight.semibold),.foregroundColor: UIColor.init(hex: 0x333333)!]
       attrString.addAttributes(attr, range: NSRange(location: 0, length: attrString.length))
        label.attributedText = attrString
       return label
    }()
}
